package diplomovka.outputCreator.xmi;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.lang.reflect.Modifier;
import java.net.URI;
import java.net.URL;
import java.sql.Blob;
import java.sql.Clob;
import java.sql.Date;
import java.sql.Time;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;

import javax.swing.tree.TreeNode;

import org.jdom.Attribute;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.Namespace;
import org.jdom.input.SAXBuilder;
import org.jdom.output.XMLOutputter;

import diplomovka.context.Context;
import diplomovka.graphCreator.modelParts.MClass;
import diplomovka.graphCreator.modelParts.MEnumeration;
import diplomovka.graphCreator.modelParts.MException;
import diplomovka.graphCreator.modelParts.MField;
import diplomovka.graphCreator.modelParts.MMethod;
import diplomovka.graphCreator.modelParts.Type;
import diplomovka.outputCreator.OutputCreator;

public class XmiOutputCreator implements OutputCreator {

	private Document doc;
	private List<Integer> entitiyIds = new ArrayList<Integer>();
	private List<Type> entitiesList = new ArrayList<Type>();
	private int entityCounter = 1;
	private int idCounter;

	@Override
	public File createOutput(Map<String, List<Object>> filteredGraph) {

		List<Object> entities = filteredGraph.get("ENTITIES");
		List<Object> services = filteredGraph.get("SERVICES");
		List<Object> valueObjects = filteredGraph.get("VALUE_OBJECTS");
		List<Object> webServices = filteredGraph.get("WEB_SERVICES");
		idCounter = entities.size() + services.size() + valueObjects.size()
				+ webServices.size() + 1;

		Element rootElement = openTemplateFile();
		if (rootElement == null)
			return null;

		Element xmiContentElement = rootElement.getChild("XMI.content");
		Element xmiExtensionsElement = rootElement.getChild("XMI.extensions");

		Element umlModelElement = xmiContentElement.getChild("Model", Namespace
				.getNamespace("omg.org/UML/1.4"));
		Element ownedElement = umlModelElement.getChild(
				"Namespace.ownedElement", Namespace
						.getNamespace("omg.org/UML/1.4"));
		Element modelElement = ownedElement.getChild("Model", Namespace
				.getNamespace("omg.org/UML/1.4"));
		modelElement.setAttribute("name", Context.getInstance()
				.getProjectName());

		ownedElement = modelElement.getChild("Namespace.ownedElement",
				Namespace.getNamespace("omg.org/UML/1.4"));

		int modelNumber = 0;
		for (String packageName : getAllPackagesFromClasses(filteredGraph)) {
			List<Object> packageEntities = filterClassesByPackageName(entities,
					packageName);
			List<Object> packageServices = filterClassesByPackageName(services,
					packageName);
			List<Object> packageValueObjects = filterClassesByPackageName(
					valueObjects, packageName);
			List<Object> packageWebServices = filterClassesByPackageName(
					webServices, packageName);

			Element packageElement = new Element("Package", "UML",
					"omg.org/UML/1.4");
			packageElement.setAttribute(new Attribute("xmi.id", Integer
					.toString(idCounter++)));
			packageElement.setAttribute(new Attribute("name", packageName));
			ownedElement.addContent(packageElement);
			Element ownedElement2 = new Element("Namespace.ownedElement",
					"UML", "omg.org/UML/1.4");
			packageElement.addContent(ownedElement2);

			if (packageEntities.size() > 0) {
				// create Entities
				Element packageElement2 = new Element("Package", "UML",
						"omg.org/UML/1.4");
				modelNumber = idCounter;
				packageElement2.setAttribute(new Attribute("xmi.id", Integer
						.toString(idCounter++)));
				packageElement2.setAttribute(new Attribute("name", "domain"));
				ownedElement2.addContent(packageElement2);
				Element ownedElement3 = new Element("Namespace.ownedElement",
						"UML", "omg.org/UML/1.4");
				packageElement2.addContent(ownedElement3);
				createEntities(ownedElement3, packageEntities);
			}
			if (packageServices.size() > 0) {
				// create Services
				Element packageElement2 = new Element("Package", "UML",
						"omg.org/UML/1.4");
				packageElement2.setAttribute(new Attribute("xmi.id", Integer
						.toString(idCounter++)));
				packageElement2.setAttribute(new Attribute("name", "service"));
				ownedElement2.addContent(packageElement2);
				Element ownedElement3 = new Element("Namespace.ownedElement",
						"UML", "omg.org/UML/1.4");
				packageElement2.addContent(ownedElement3);
				createServices(ownedElement3, packageServices);
			}
			if (packageValueObjects.size() > 0) {
				// create Value objects
				Element packageElement2 = new Element("Package", "UML",
						"omg.org/UML/1.4");
				packageElement2.setAttribute(new Attribute("xmi.id", Integer
						.toString(idCounter++)));
				packageElement2.setAttribute(new Attribute("name", "vo"));
				ownedElement2.addContent(packageElement2);
				Element ownedElement3 = new Element("Namespace.ownedElement",
						"UML", "omg.org/UML/1.4");
				packageElement2.addContent(ownedElement3);
				createValueObjects(ownedElement3, packageValueObjects);
			}
			if (packageWebServices.size() > 0) {
				// create WebServices
				Element packageElement2 = new Element("Package", "UML",
						"omg.org/UML/1.4");
				packageElement2.setAttribute(new Attribute("xmi.id", Integer
						.toString(idCounter++)));
				packageElement2
						.setAttribute(new Attribute("name", "webservice"));
				ownedElement2.addContent(packageElement2);
				Element ownedElement3 = new Element("Namespace.ownedElement",
						"UML", "omg.org/UML/1.4");
				packageElement2.addContent(ownedElement3);
				createWebServices(ownedElement3, packageWebServices);
			}
		}

		createEntityReferences(xmiExtensionsElement, entities.size()
				+ services.size() + valueObjects.size(), idCounter, modelNumber);
		XMLOutputter outputter = new XMLOutputter();
		try {
			outputter.output(doc, new FileOutputStream(
					"../OutputCreator/config/output.xmi"));
		} catch (FileNotFoundException e) {
		} catch (IOException e) {
		}
		return null;
	}

	private Element openTemplateFile() {
		SAXBuilder builder = new SAXBuilder();
		try {
			doc = builder
					.build(new File("../OutputCreator/config/template.xmi"));
			Element rootElement = doc.getRootElement();

			return rootElement;
		} catch (JDOMException e) {
			System.out
					.println("Can't process output template fiel as JDOM object.");
			System.out.println(e.getMessage());
		} catch (IOException e) {
			System.out.println("Can't open output template file.");
			System.out.println(e.getMessage());
		}

		return null;
	}

	private Element getElementWithSpecifiedName(Element ownedElement,
			String attr, String name) {
		List<Element> packageElements = ownedElement.getChildren();
		for (Element packageElement2 : packageElements) {
			Attribute nameAttribute = packageElement2.getAttribute(attr);
			String attrName = nameAttribute.getValue();
			if (attrName.equals(name))
				return packageElement2;
		}

		return null;
	}

	private void createEntities(Element ownedElement, List<Object> entities) {
		for (Object entity : entities) {
			Type entityClass = (Type) entity;
			List<Element> ownedElementCHildren = ownedElement.getChildren();

			Element entityElement = new Element("Class", Namespace
					.getNamespace("UML", "omg.org/UML/1.4"));
			List<Element> entityElementChildren = entityElement.getChildren();
			entitiyIds.add(entityCounter);
			entitiesList.add(entityClass);
			Attribute idAttribute = new Attribute("xmi.id", Integer
					.toString(entityCounter++));
			Attribute nameAttribute = new Attribute("name", entityClass
					.getName());
			entityElement.setAttribute(idAttribute);
			entityElement.setAttribute(nameAttribute);
			ownedElementCHildren.add(entityElement);

			Element stereotypeModelElement = new Element(
					"ModelElement.stereotype", Namespace.getNamespace("UML",
							"omg.org/UML/1.4"));
			entityElementChildren.add(stereotypeModelElement);
			List<Element> stereotypeModelElementChildren = stereotypeModelElement
					.getChildren();

			Element stereotypeElement = new Element("Stereotype", Namespace
					.getNamespace("UML", "omg.org/UML/1.4"));
			Attribute hrefAttribute = null;
			if (entityClass instanceof MEnumeration) {
				hrefAttribute = new Attribute("href",
						"andromda-profile-3.3.xml.zip|_9_0_1fe00f9_1119373197267_700962_14");
			} else {
				if (entityClass instanceof MException) {
					hrefAttribute = new Attribute("href",
							"andromda-profile-3.3.xml.zip|_9_0_1fe00f9_1119373197267_116094_8");
				} else {
					hrefAttribute = new Attribute("href",
							"andromda-profile-persistence-3.3.xml.zip|_9_0_1fe00f9_1119337118921_354011_73");
				}
			}
			stereotypeElement.setAttribute(hrefAttribute);
			stereotypeModelElementChildren.add(stereotypeElement);
			List<Element> stereotypeElementChildren = stereotypeElement
					.getChildren();

			Element xmiExtensionElement = new Element("XMI.extension");
			Attribute extenderAttribute = new Attribute("xmi.extender",
					"MagicDraw UML 9.5");
			Attribute extenderIDAttribute = new Attribute("xmi.extenderID",
					"MagicDraw UML 9.5");
			xmiExtensionElement.setAttribute(extenderAttribute);
			xmiExtensionElement.setAttribute(extenderIDAttribute);
			stereotypeElementChildren.add(xmiExtensionElement);
			List<Element> xmiExtensionElementChildren = xmiExtensionElement
					.getChildren();

			Element referentPathElement = new Element("referentPath");
			Attribute valueAttribute = null;
			if (entityClass instanceof MEnumeration) {
				valueAttribute = new Attribute("xmi.value",
						"org.andromda.profile::Enumeration");
			} else {
				if (entityClass instanceof MException) {
					valueAttribute = new Attribute("xmi.value",
							"org.andromda.profile::ApplicationException");
				} else {
					valueAttribute = new Attribute("xmi.value",
							"org.andromda.profile::persistence::Entity");
				}
			}
			referentPathElement.setAttribute(valueAttribute);
			xmiExtensionElementChildren.add(referentPathElement);

			// fields
			Element featureElement = new Element("Classifier.feature",
					Namespace.getNamespace("UML", "omg.org/UML/1.4"));
			entityElementChildren.add(featureElement);
			List<Element> featureElementChildren = featureElement.getChildren();

			List<MField> fields = entityClass.getFields();
			for (MField field : fields) {
				if (isBuildedDataType(field.getType())) {
					Element attributeElement = new Element("Attribute",
							Namespace.getNamespace("UML", "omg.org/UML/1.4"));
					Attribute attributeIDAttribute = new Attribute("xmi.id",
							Integer.toString(idCounter++));
					Attribute attributeNameAttribute = new Attribute("name",
							field.getName());
					String visibility = "package";
					int modifiers = field.getModifiers();
					String modifierString = Modifier.toString(modifiers);
					if (modifierString.contains("public")) {
						visibility = "public";
					}
					if (modifierString.contains("private")) {
						visibility = "private";
					}
					if (modifierString.contains("protected")) {
						visibility = "protected";
					}

					Attribute attributeVisibilityAttribute = new Attribute(
							"visibility", visibility);
					attributeElement.setAttribute(attributeIDAttribute);
					attributeElement.setAttribute(attributeNameAttribute);
					attributeElement.setAttribute(attributeVisibilityAttribute);
					featureElementChildren.add(attributeElement);
					List<Element> attributeElementChildren = attributeElement
							.getChildren();

					if (field.isStaticField())
						addUniqueStereotypeToAttribute(attributeElementChildren);
					if (field.isNotNull())
						addNotNullRangeToAttribute(attributeElementChildren);
					if (field.isIdentifier())
						addIdentifierStereotypeToAttribute(attributeElementChildren);

					if (entityClass instanceof MEnumeration) {
						Element initialValuElement = new Element(
								"Attribute.initialValue", Namespace
										.getNamespace("UML", "omg.org/UML/1.4"));
						attributeElementChildren.add(initialValuElement);
						Element expressionElement = new Element("Expression",
								Namespace
										.getNamespace("UML", "omg.org/UML/1.4"));
						initialValuElement.addContent(expressionElement);
						expressionElement.setAttribute("xmi.id", Integer
								.toString(idCounter++));
					}

					Element featureTypeElement = new Element(
							"StructuralFeature.type", Namespace.getNamespace(
									"UML", "omg.org/UML/1.4"));
					attributeElementChildren.add(featureTypeElement);
					List<Element> featureTypeElementChildren = featureTypeElement
							.getChildren();

					Element classifierElement = new Element("Classifier",
							Namespace.getNamespace("UML", "omg.org/UML/1.4"));
					Attribute classifierHref = new Attribute("href",
							"andromda-profile-datatype-3.3.xml.zip|"
									+ getDataTypeCode(field.getType()));
					classifierElement.setAttribute(classifierHref);
					featureTypeElementChildren.add(classifierElement);
					List<Element> classifierElementChildren = classifierElement
							.getChildren();

					Element xmiExtensionElement2 = new Element("XMI.extension");
					Attribute extenderAttribute2 = new Attribute(
							"xmi.extender", "MagicDraw UML 9.5");
					Attribute extenderIDAttribute2 = new Attribute(
							"xmi.extenderID", "MagicDraw UML 9.5");
					xmiExtensionElement2.setAttribute(extenderAttribute2);
					xmiExtensionElement2.setAttribute(extenderIDAttribute2);
					classifierElementChildren.add(xmiExtensionElement2);
					List<Element> xmiExtensionElementChildren2 = xmiExtensionElement2
							.getChildren();

					Element referentPathElement2 = new Element("referentPath");
					Attribute valueAttribute2 = new Attribute("xmi.value",
							"datatype::" + field.getType().getSimpleName());
					referentPathElement2.setAttribute(valueAttribute2);
					xmiExtensionElementChildren2.add(referentPathElement2);
				} else {
					if (entityClass instanceof MClass) {
						boolean shouldBeExported = isClassExported(field
								.getType().getName(), entities);
						if (shouldBeExported) {
							Element associationElement = new Element(
									"Association", Namespace.getNamespace(
											"UML", "omg.org/UML/1.4"));
							Attribute associationIdAttribute = new Attribute(
									"xmi.id", Integer.toString(idCounter++));
							associationElement
									.setAttribute(associationIdAttribute);
							ownedElementCHildren.add(associationElement);
							List<Element> associationElementChildren = associationElement
									.getChildren();

							Element associationConnectionElement = new Element(
									"Association.connection", Namespace
											.getNamespace("UML",
													"omg.org/UML/1.4"));
							associationElementChildren
									.add(associationConnectionElement);
							List<Element> associationConnectionChildren = associationConnectionElement
									.getChildren();

							Element associationEndElement = new Element(
									"AssociationEnd", Namespace.getNamespace(
											"UML", "omg.org/UML/1.4"));
							Attribute associationEndIDAttribute = new Attribute(
									"xmi.id", Integer.toString(idCounter++));
							Attribute associationEndName = new Attribute(
									"name", field.getName());
							Attribute associationIsNavigable = new Attribute(
									"isNavigable", "true");
							Attribute associationParticipantAttribute = new Attribute(
									"participant", idAttribute.getValue());
							if (field.isAggregation()) {
								Attribute associationAggregate = new Attribute(
										"aggregation", "aggregate");
								associationEndElement
										.setAttribute(associationAggregate);
							}
							associationEndElement
									.setAttribute(associationEndIDAttribute);
							associationEndElement
									.setAttribute(associationEndName);
							associationEndElement
									.setAttribute(associationIsNavigable);
							associationEndElement
									.setAttribute(associationParticipantAttribute);
							associationConnectionChildren
									.add(associationEndElement);
							List<Element> associationEndChildren = associationEndElement
									.getChildren();

							Element associationEndMultiplicityElement = new Element(
									"AssociationEnd.multiplicity", Namespace
											.getNamespace("UML",
													"omg.org/UML/1.4"));
							associationEndChildren
									.add(associationEndMultiplicityElement);
							List<Element> associationEndMultiplicityChildren = associationEndMultiplicityElement
									.getChildren();

							Element umlMultiplicityElement = new Element(
									"Multiplicity", Namespace.getNamespace(
											"UML", "omg.org/UML/1.4"));
							List<Element> umlMultiplicityChildren = umlMultiplicityElement
									.getChildren();
							associationEndMultiplicityChildren
									.add(umlMultiplicityElement);
							Attribute umlMultiplicityIDAttribute = new Attribute(
									"xmi.id", Integer.toString(idCounter++));
							umlMultiplicityElement
									.setAttribute(umlMultiplicityIDAttribute);

							Element multiplicityRangeElement = new Element(
									"Multiplicity.range", Namespace
											.getNamespace("UML",
													"omg.org/UML/1.4"));
							List<Element> multiplictyRangeChildren = multiplicityRangeElement
									.getChildren();
							umlMultiplicityChildren
									.add(multiplicityRangeElement);

							Element umlMultiplicityRangeElement = new Element(
									"MultiplicityRange", Namespace
											.getNamespace("UML",
													"omg.org/UML/1.4"));
							List<Element> umlMultiplicityRangeChildren = umlMultiplicityRangeElement
									.getChildren();
							multiplictyRangeChildren
									.add(umlMultiplicityRangeElement);
							Attribute multiplictyIDAttribute = new Attribute(
									"xmi.id", Integer.toString(idCounter++));
							Attribute lowerAttribute = new Attribute("lower",
									getLowerMultiplictyOfField(field, entities));
							Attribute upperAttribute = new Attribute("upper",
									getUpperMultiplictyOfField(field, entities));
							umlMultiplicityRangeElement
									.setAttribute(multiplictyIDAttribute);
							umlMultiplicityRangeElement
									.setAttribute(lowerAttribute);
							umlMultiplicityRangeElement
									.setAttribute(upperAttribute);

							if (field.getCascade() != null
									&& !field.getCascade().equals("")) {
								Element taggedValuElement = new Element(
										"ModelElement.taggedValue", Namespace
												.getNamespace("UML",
														"omg.org/UML/1.4"));
								associationEndElement
										.addContent(taggedValuElement);
								Element taggedValuElement2 = new Element(
										"TaggedValue", Namespace.getNamespace(
												"UML", "omg.org/UML/1.4"));
								taggedValuElement
										.addContent(taggedValuElement2);
								taggedValuElement2.setAttribute("xmi.id",
										Integer.toString(idCounter++));
								taggedValuElement2.setAttribute("name",
										"@andromda.hibernate.cascade");

								Element dataValuElement = new Element(
										"TaggedValue.dataValue", Namespace
												.getNamespace("UML",
														"omg.org/UML/1.4"));
								taggedValuElement2.addContent(dataValuElement);
								dataValuElement.setText(field.getCascade());

								Element typElement = new Element(
										"TaggedValue.type", Namespace
												.getNamespace("UML",
														"omg.org/UML/1.4"));
								taggedValuElement2.addContent(typElement);

								Element tagDefinitionElement = new Element(
										"TagDefinition", Namespace
												.getNamespace("UML",
														"omg.org/UML/1.4"));
								typElement.addContent(tagDefinitionElement);
								tagDefinitionElement
										.setAttribute(
												"href",
												"andromda-profile-persistence-3.3.xml.zip|_9_0_2_1fe00f9_1123571135734_378565_0");

								Element xmiExtensionElement2 = new Element(
										"XMI.extension");
								tagDefinitionElement
										.addContent(xmiExtensionElement2);
								xmiExtensionElement2.setAttribute(
										"xmi.extender", "MagicDraw UML 9.5");
								xmiExtensionElement2.setAttribute(
										"xmi.extenderID", "MagicDraw UML 9.5");

								Element referentPathElement2 = new Element(
										"referentPath");
								xmiExtensionElement2
										.addContent(referentPathElement2);
								referentPathElement2
										.setAttribute("xmi.value",
												"org.andromda.profile::persistence::@andromda.hibernate.cascade");
							}

							Element associationEnd2Element = new Element(
									"AssociationEnd", Namespace.getNamespace(
											"UML", "omg.org/UML/1.4"));
							Attribute associationEnd2IDAttribute = new Attribute(
									"xmi.id", Integer.toString(idCounter++));
							Attribute association2IsNavigable = new Attribute(
									"isNavigable", "true");
							Attribute association2ParticipantAttribute = new Attribute(
									"participant", getEntityId(field.getType()
											.getName(), entities));
							associationEnd2Element
									.setAttribute(associationEnd2IDAttribute);
							associationEnd2Element
									.setAttribute(association2IsNavigable);
							associationEnd2Element
									.setAttribute(association2ParticipantAttribute);
							associationConnectionChildren
									.add(associationEnd2Element);
						}
					}
				}
			}

			// methods
			List<MMethod> methods = entityClass.getMethods();
			for (MMethod method : methods) {
				if (!isSetterOrGetterMethod(method, fields)) {
					Element operationElement = new Element("Operation",
							Namespace.getNamespace("UML", "omg.org/UML/1.4"));
					Attribute operationIDAttribute = new Attribute("xmi.id",
							Integer.toString(idCounter++));
					Attribute operationNameAttribute = new Attribute("name",
							method.getName());
					String visibility = "package";
					int modifiers = method.getModifiers();
					String modifierString = Modifier.toString(modifiers);
					if (modifierString.contains("public")) {
						visibility = "public";
					}
					if (modifierString.contains("private")) {
						visibility = "private";
					}
					if (modifierString.contains("protected")) {
						visibility = "protected";
					}

					Attribute methodVisibilityAttribute = new Attribute(
							"visibility", visibility);
					operationElement.setAttribute(operationIDAttribute);
					operationElement.setAttribute(operationNameAttribute);
					operationElement.setAttribute(methodVisibilityAttribute);
					addOwnerScopeAttribute(method, operationElement);
					featureElementChildren.add(operationElement);
					List<Element> operationElementChildren = operationElement
							.getChildren();

					Element behavioralFeatureElement = new Element(
							"BehavioralFeature.parameter", Namespace
									.getNamespace("UML", "omg.org/UML/1.4"));
					operationElementChildren.add(behavioralFeatureElement);
					List<Element> behavioralFeatureElementChildren = behavioralFeatureElement
							.getChildren();

					Element returnParameterElement = new Element("Parameter",
							Namespace.getNamespace("UML", "omg.org/UML/1.4"));
					Attribute parameterIDAttribute = new Attribute("xmi.id",
							Integer.toString(idCounter++));
					Attribute parameterKindAttribute = new Attribute("kind",
							"return");
					returnParameterElement.setAttribute(parameterIDAttribute);
					returnParameterElement.setAttribute(parameterKindAttribute);
					behavioralFeatureElementChildren
							.add(returnParameterElement);
					List<Element> returnParameterElementChildren = returnParameterElement
							.getChildren();

					Element parameterTypElement2 = new Element(
							"Parameter.type", Namespace.getNamespace("UML",
									"omg.org/UML/1.4"));
					returnParameterElementChildren.add(parameterTypElement2);
					List<Element> parameterTypElementChildren2 = parameterTypElement2
							.getChildren();

					Element classifierElement2 = new Element("Classifier",
							Namespace.getNamespace("UML", "omg.org/UML/1.4"));
					Attribute classifierHref2 = new Attribute("href",
							"andromda-profile-datatype-3.3.xml.zip|"
									+ getDataTypeCode(method.getReturnType()));
					classifierElement2.setAttribute(classifierHref2);
					parameterTypElementChildren2.add(classifierElement2);
					List<Element> classifierElementChildren2 = classifierElement2
							.getChildren();

					Element xmiExtensionElement3 = new Element("XMI.extension");
					Attribute extenderAttribute3 = new Attribute(
							"xmi.extender", "MagicDraw UML 9.5");
					Attribute extenderIDAttribute3 = new Attribute(
							"xmi.extenderID", "MagicDraw UML 9.5");
					xmiExtensionElement3.setAttribute(extenderAttribute3);
					xmiExtensionElement3.setAttribute(extenderIDAttribute3);
					classifierElementChildren2.add(xmiExtensionElement3);
					List<Element> xmiExtensionElementChildren3 = xmiExtensionElement3
							.getChildren();

					Element referentPathElement3 = new Element("referentPath");
					Attribute valueAttribute3 = new Attribute("xmi.value",
							method.getReturnType().getSimpleName());
					referentPathElement3.setAttribute(valueAttribute3);
					xmiExtensionElementChildren3.add(referentPathElement3);

					Map<String, Class> parameters = method.getParameters();
					Set<String> nameSet = parameters.keySet();
					for (String parameterName : nameSet) {
						Element parameterElement = new Element("Parameter",
								Namespace
										.getNamespace("UML", "omg.org/UML/1.4"));
						Attribute parameterIDAttribute2 = new Attribute(
								"xmi.id", Integer.toString(idCounter++));
						Attribute parameterKindAttribute2 = new Attribute(
								"name", parameterName);
						parameterElement.setAttribute(parameterIDAttribute2);
						parameterElement.setAttribute(parameterKindAttribute2);
						behavioralFeatureElementChildren.add(parameterElement);
						List<Element> parameterElementChildren = parameterElement
								.getChildren();

						Element parameterTypElement = new Element(
								"Parameter.type", Namespace.getNamespace("UML",
										"omg.org/UML/1.4"));
						parameterElementChildren.add(parameterTypElement);
						List<Element> parameterTypElementChildren = parameterTypElement
								.getChildren();

						Element classifierElement = new Element("Classifier",
								Namespace
										.getNamespace("UML", "omg.org/UML/1.4"));
						Attribute classifierHref = new Attribute("href",
								"andromda-profile-datatype-3.3.xml.zip|"
										+ getDataTypeCode(parameters
												.get(parameterName)));
						classifierElement.setAttribute(classifierHref);
						parameterTypElementChildren.add(classifierElement);
						List<Element> classifierElementChildren = classifierElement
								.getChildren();

						Element xmiExtensionElement2 = new Element(
								"XMI.extension");
						Attribute extenderAttribute2 = new Attribute(
								"xmi.extender", "MagicDraw UML 9.5");
						Attribute extenderIDAttribute2 = new Attribute(
								"xmi.extenderID", "MagicDraw UML 9.5");
						xmiExtensionElement2.setAttribute(extenderAttribute2);
						xmiExtensionElement2.setAttribute(extenderIDAttribute2);
						classifierElementChildren.add(xmiExtensionElement2);
						List<Element> xmiExtensionElementChildren2 = xmiExtensionElement2
								.getChildren();

						Element referentPathElement2 = new Element(
								"referentPath");
						Attribute valueAttribute2 = new Attribute("xmi.value",
								parameters.get(parameterName).getSimpleName());
						referentPathElement2.setAttribute(valueAttribute2);
						xmiExtensionElementChildren2.add(referentPathElement2);
					}
				}
			}

			List<MMethod> queryMethods = entityClass.getQueriesMethods();
			for (MMethod method : queryMethods) {
				Element operationElement = new Element("Operation", Namespace
						.getNamespace("UML", "omg.org/UML/1.4"));
				Attribute operationIDAttribute = new Attribute("xmi.id",
						Integer.toString(idCounter++));
				Attribute operationNameAttribute = new Attribute("name", method
						.getName());
				String visibility = "package";
				int modifiers = method.getModifiers();
				String modifierString = Modifier.toString(modifiers);
				if (modifierString.contains("public")) {
					visibility = "public";
				}
				if (modifierString.contains("private")) {
					visibility = "private";
				}
				if (modifierString.contains("protected")) {
					visibility = "protected";
				}

				Attribute methodVisibilityAttribute = new Attribute(
						"visibility", visibility);
				Attribute isQueryAttribute = new Attribute("isQuery", "true");

				operationElement.setAttribute(operationIDAttribute);
				operationElement.setAttribute(operationNameAttribute);
				operationElement.setAttribute(methodVisibilityAttribute);
				operationElement.setAttribute(isQueryAttribute);
				featureElementChildren.add(operationElement);
				List<Element> operationElementChildren = operationElement
						.getChildren();

				Element behavioralFeatureElement = new Element(
						"BehavioralFeature.parameter", Namespace.getNamespace(
								"UML", "omg.org/UML/1.4"));
				operationElementChildren.add(behavioralFeatureElement);
				List<Element> behavioralFeatureElementChildren = behavioralFeatureElement
						.getChildren();

				Element returnParameterElement = new Element("Parameter",
						Namespace.getNamespace("UML", "omg.org/UML/1.4"));
				Attribute parameterIDAttribute = new Attribute("xmi.id",
						Integer.toString(idCounter++));
				Attribute parameterKindAttribute = new Attribute("kind",
						"return");
				returnParameterElement.setAttribute(parameterIDAttribute);
				returnParameterElement.setAttribute(parameterKindAttribute);
				behavioralFeatureElementChildren.add(returnParameterElement);
				List<Element> returnParameterElementChildren = returnParameterElement
						.getChildren();

				Element parameterTypElement2 = new Element("Parameter.type",
						Namespace.getNamespace("UML", "omg.org/UML/1.4"));
				returnParameterElementChildren.add(parameterTypElement2);
				List<Element> parameterTypElementChildren2 = parameterTypElement2
						.getChildren();

				Element classifierElement2 = new Element("Classifier",
						Namespace.getNamespace("UML", "omg.org/UML/1.4"));
				Attribute classifierHref2 = new Attribute("href",
						"andromda-profile-datatype-3.3.xml.zip|_9_0_1fe00f9_1119336925531_364079_66");
				classifierElement2.setAttribute(classifierHref2);
				parameterTypElementChildren2.add(classifierElement2);
				List<Element> classifierElementChildren2 = classifierElement2
						.getChildren();

				Element xmiExtensionElement3 = new Element("XMI.extension");
				Attribute extenderAttribute3 = new Attribute("xmi.extender",
						"MagicDraw UML 9.5");
				Attribute extenderIDAttribute3 = new Attribute(
						"xmi.extenderID", "MagicDraw UML 9.5");
				xmiExtensionElement3.setAttribute(extenderAttribute3);
				xmiExtensionElement3.setAttribute(extenderIDAttribute3);
				classifierElementChildren2.add(xmiExtensionElement3);
				List<Element> xmiExtensionElementChildren3 = xmiExtensionElement3
						.getChildren();

				Element referentPathElement3 = new Element("referentPath");
				Attribute valueAttribute3 = new Attribute("xmi.value", method
						.getReturnType().getSimpleName());
				referentPathElement3.setAttribute(valueAttribute3);
				xmiExtensionElementChildren3.add(referentPathElement3);

				Map<String, Class> parameters = method.getParameters();
				Set<String> nameSet = parameters.keySet();
				for (String parameterName : nameSet) {
					Element parameterElement = new Element("Parameter",
							Namespace.getNamespace("UML", "omg.org/UML/1.4"));
					Attribute parameterIDAttribute2 = new Attribute("xmi.id",
							Integer.toString(idCounter++));
					Attribute parameterKindAttribute2 = new Attribute("name",
							parameterName);
					parameterElement.setAttribute(parameterIDAttribute2);
					parameterElement.setAttribute(parameterKindAttribute2);
					behavioralFeatureElementChildren.add(parameterElement);
					List<Element> parameterElementChildren = parameterElement
							.getChildren();

					Element parameterTypElement = new Element("Parameter.type",
							Namespace.getNamespace("UML", "omg.org/UML/1.4"));
					parameterElementChildren.add(parameterTypElement);
					List<Element> parameterTypElementChildren = parameterTypElement
							.getChildren();

					Element classifierElement = new Element("Classifier",
							Namespace.getNamespace("UML", "omg.org/UML/1.4"));
					Attribute classifierHref = new Attribute("href",
							"andromda-profile-datatype-3.3.xml.zip|_9_0_1fe00f9_1119336925531_364079_66");
					classifierElement.setAttribute(classifierHref);
					parameterTypElementChildren.add(classifierElement);
					List<Element> classifierElementChildren = classifierElement
							.getChildren();

					Element xmiExtensionElement2 = new Element("XMI.extension");
					Attribute extenderAttribute2 = new Attribute(
							"xmi.extender", "MagicDraw UML 9.5");
					Attribute extenderIDAttribute2 = new Attribute(
							"xmi.extenderID", "MagicDraw UML 9.5");
					xmiExtensionElement2.setAttribute(extenderAttribute2);
					xmiExtensionElement2.setAttribute(extenderIDAttribute2);
					classifierElementChildren.add(xmiExtensionElement2);
					List<Element> xmiExtensionElementChildren2 = xmiExtensionElement2
							.getChildren();

					Element referentPathElement2 = new Element("referentPath");
					Attribute valueAttribute2 = new Attribute("xmi.value",
							parameters.get(parameterName).getSimpleName());
					referentPathElement2.setAttribute(valueAttribute2);
					xmiExtensionElementChildren2.add(referentPathElement2);
				}
			}

			MClass superClass = entityClass.getSupertype();
			if (entityClass instanceof MClass) {
				if (isClassExported(superClass.getName().substring(
						"class ".length()), entities)) {
					Element generalizationElement = new Element(
							"Generalization", Namespace.getNamespace("UML",
									"omg.org/UML/1.4"));
					Attribute generalizationIDAttribute = new Attribute(
							"xmi.id", Integer.toString(idCounter++));
					Attribute generalizationChildId = new Attribute("child",
							idAttribute.getValue());
					Attribute generalizationParentId = new Attribute("parent",
							getEntityId(superClass.getName().substring(
									"class ".length()), entities));
					generalizationElement
							.setAttribute(generalizationIDAttribute);
					generalizationElement.setAttribute(generalizationChildId);
					generalizationElement.setAttribute(generalizationParentId);
					ownedElementCHildren.add(generalizationElement);
				}
			}
		}
	}

	private void createServices(Element ownedElement, List<Object> entities) {
		for (Object entity : entities) {
			MClass entityClass = (MClass) entity;
			List<Element> ownedElementCHildren = ownedElement.getChildren();

			Element entityElement = new Element("Class", Namespace
					.getNamespace("UML", "omg.org/UML/1.4"));
			List<Element> entityElementChildren = entityElement.getChildren();
			entitiyIds.add(entityCounter);
			entitiesList.add(entityClass);
			Attribute idAttribute = new Attribute("xmi.id", Integer
					.toString(entityCounter++));
			Attribute nameAttribute = new Attribute("name", entityClass
					.getName());
			entityElement.setAttribute(idAttribute);
			entityElement.setAttribute(nameAttribute);
			ownedElementCHildren.add(entityElement);

			Element stereotypeModelElement = new Element(
					"ModelElement.stereotype", Namespace.getNamespace("UML",
							"omg.org/UML/1.4"));
			entityElementChildren.add(stereotypeModelElement);
			List<Element> stereotypeModelElementChildren = stereotypeModelElement
					.getChildren();

			Element stereotypeElement = new Element("Stereotype", Namespace
					.getNamespace("UML", "omg.org/UML/1.4"));
			Attribute hrefAttribute = new Attribute("href",
					"andromda-profile-service-3.3.xml.zip|_9_0_1fe00f9_1119337557859_21792_59");
			stereotypeElement.setAttribute(hrefAttribute);
			stereotypeModelElementChildren.add(stereotypeElement);
			List<Element> stereotypeElementChildren = stereotypeElement
					.getChildren();

			Element xmiExtensionElement = new Element("XMI.extension");
			Attribute extenderAttribute = new Attribute("xmi.extender",
					"MagicDraw UML 9.5");
			Attribute extenderIDAttribute = new Attribute("xmi.extenderID",
					"MagicDraw UML 9.5");
			xmiExtensionElement.setAttribute(extenderAttribute);
			xmiExtensionElement.setAttribute(extenderIDAttribute);
			stereotypeElementChildren.add(xmiExtensionElement);
			List<Element> xmiExtensionElementChildren = xmiExtensionElement
					.getChildren();

			Element referentPathElement = new Element("referentPath");
			Attribute valueAttribute = new Attribute("xmi.value",
					"org.andromda.profile::service::Service");
			referentPathElement.setAttribute(valueAttribute);
			xmiExtensionElementChildren.add(referentPathElement);

			Element featureElement = new Element("Classifier.feature",
					Namespace.getNamespace("UML", "omg.org/UML/1.4"));
			entityElementChildren.add(featureElement);
			List<Element> featureElementChildren = featureElement.getChildren();

			// methods
			List<MMethod> methods = entityClass.getMethods();
			for (MMethod method : methods) {
				Element operationElement = new Element("Operation", Namespace
						.getNamespace("UML", "omg.org/UML/1.4"));
				Attribute operationIDAttribute = new Attribute("xmi.id",
						Integer.toString(idCounter++));
				Attribute operationNameAttribute = new Attribute("name", method
						.getName());
				String visibility = "package";
				int modifiers = method.getModifiers();
				String modifierString = Modifier.toString(modifiers);
				if (modifierString.contains("public")) {
					visibility = "public";
				}
				if (modifierString.contains("private")) {
					visibility = "private";
				}
				if (modifierString.contains("protected")) {
					visibility = "protected";
				}

				Attribute methodVisibilityAttribute = new Attribute(
						"visibility", visibility);
				operationElement.setAttribute(operationIDAttribute);
				operationElement.setAttribute(operationNameAttribute);
				operationElement.setAttribute(methodVisibilityAttribute);
				addOwnerScopeAttribute(method, operationElement);
				featureElementChildren.add(operationElement);
				List<Element> operationElementChildren = operationElement
						.getChildren();

				Element behavioralFeatureElement = new Element(
						"BehavioralFeature.parameter", Namespace.getNamespace(
								"UML", "omg.org/UML/1.4"));
				operationElementChildren.add(behavioralFeatureElement);
				List<Element> behavioralFeatureElementChildren = behavioralFeatureElement
						.getChildren();

				Element returnParameterElement = new Element("Parameter",
						Namespace.getNamespace("UML", "omg.org/UML/1.4"));
				Attribute parameterIDAttribute = new Attribute("xmi.id",
						Integer.toString(idCounter++));
				Attribute parameterKindAttribute = new Attribute("kind",
						"return");
				returnParameterElement.setAttribute(parameterIDAttribute);
				returnParameterElement.setAttribute(parameterKindAttribute);
				behavioralFeatureElementChildren.add(returnParameterElement);
				List<Element> returnParameterElementChildren = returnParameterElement
						.getChildren();

				if (isBuildedDataType(method.getReturnType())) {
					Element parameterTypElement2 = new Element(
							"Parameter.type", Namespace.getNamespace("UML",
									"omg.org/UML/1.4"));
					returnParameterElementChildren.add(parameterTypElement2);
					List<Element> parameterTypElementChildren2 = parameterTypElement2
							.getChildren();

					Element classifierElement2 = new Element("Classifier",
							Namespace.getNamespace("UML", "omg.org/UML/1.4"));
					Attribute classifierHref2 = new Attribute("href",
							"andromda-profile-datatype-3.3.xml.zip|"
									+ getDataTypeCode(method.getReturnType()));
					classifierElement2.setAttribute(classifierHref2);
					parameterTypElementChildren2.add(classifierElement2);
					List<Element> classifierElementChildren2 = classifierElement2
							.getChildren();

					Element xmiExtensionElement3 = new Element("XMI.extension");
					Attribute extenderAttribute3 = new Attribute(
							"xmi.extender", "MagicDraw UML 9.5");
					Attribute extenderIDAttribute3 = new Attribute(
							"xmi.extenderID", "MagicDraw UML 9.5");
					xmiExtensionElement3.setAttribute(extenderAttribute3);
					xmiExtensionElement3.setAttribute(extenderIDAttribute3);
					classifierElementChildren2.add(xmiExtensionElement3);
					List<Element> xmiExtensionElementChildren3 = xmiExtensionElement3
							.getChildren();

					Element referentPathElement3 = new Element("referentPath");
					Attribute valueAttribute3 = new Attribute("xmi.value",
							method.getReturnType().getSimpleName());
					referentPathElement3.setAttribute(valueAttribute3);
					xmiExtensionElementChildren3.add(referentPathElement3);
				} else {
					returnParameterElement.setAttribute("type",
							getEntityIdForMClass(method.getReturnType()
									.getName(), entitiesList));
				}

				Map<String, Class> parameters = method.getParameters();
				Set<String> nameSet = parameters.keySet();
				for (String parameterName : nameSet) {
					Element parameterElement = new Element("Parameter",
							Namespace.getNamespace("UML", "omg.org/UML/1.4"));
					Attribute parameterIDAttribute2 = new Attribute("xmi.id",
							Integer.toString(idCounter++));
					Attribute parameterKindAttribute2 = new Attribute("name",
							parameterName);
					parameterElement.setAttribute(parameterIDAttribute2);
					parameterElement.setAttribute(parameterKindAttribute2);
					behavioralFeatureElementChildren.add(parameterElement);
					List<Element> parameterElementChildren = parameterElement
							.getChildren();

					if (isBuildedDataType(parameters.get(parameterName))) {
						Element parameterTypElement = new Element(
								"Parameter.type", Namespace.getNamespace("UML",
										"omg.org/UML/1.4"));
						parameterElementChildren.add(parameterTypElement);
						List<Element> parameterTypElementChildren = parameterTypElement
								.getChildren();

						Element classifierElement = new Element("Classifier",
								Namespace
										.getNamespace("UML", "omg.org/UML/1.4"));
						Attribute classifierHref = new Attribute("href",
								"andromda-profile-datatype-3.3.xml.zip|"
										+ getDataTypeCode(parameters
												.get(parameterName)));
						classifierElement.setAttribute(classifierHref);
						parameterTypElementChildren.add(classifierElement);
						List<Element> classifierElementChildren = classifierElement
								.getChildren();

						Element xmiExtensionElement2 = new Element(
								"XMI.extension");
						Attribute extenderAttribute2 = new Attribute(
								"xmi.extender", "MagicDraw UML 9.5");
						Attribute extenderIDAttribute2 = new Attribute(
								"xmi.extenderID", "MagicDraw UML 9.5");
						xmiExtensionElement2.setAttribute(extenderAttribute2);
						xmiExtensionElement2.setAttribute(extenderIDAttribute2);
						classifierElementChildren.add(xmiExtensionElement2);
						List<Element> xmiExtensionElementChildren2 = xmiExtensionElement2
								.getChildren();

						Element referentPathElement2 = new Element(
								"referentPath");
						Attribute valueAttribute2 = new Attribute("xmi.value",
								parameters.get(parameterName).getSimpleName());
						referentPathElement2.setAttribute(valueAttribute2);
						xmiExtensionElementChildren2.add(referentPathElement2);
					} else {
						parameterElement
								.setAttribute("type",
										getEntityIdForMClass(parameters.get(
												parameterName).getName(),
												entitiesList));
					}
				}
			}
		}
	}

	private void createWebServices(Element ownedElement,
			List<Object> webServices) {
		for (Object webService : webServices) {
			MClass entityClass = (MClass) webService;
			if (entityClass.isHasWebServiceConfig()) {
				List<Element> ownedElementCHildren = ownedElement.getChildren();

				Element entityElement = new Element("Class", Namespace
						.getNamespace("UML", "omg.org/UML/1.4"));
				List<Element> entityElementChildren = entityElement
						.getChildren();
				entitiyIds.add(entityCounter);
				entitiesList.add(entityClass);
				Attribute idAttribute = new Attribute("xmi.id", Integer
						.toString(entityCounter++));
				Attribute nameAttribute = new Attribute("name", entityClass
						.getName());
				entityElement.setAttribute(idAttribute);
				entityElement.setAttribute(nameAttribute);
				ownedElementCHildren.add(entityElement);

				Element stereotypeModelElement = new Element(
						"ModelElement.stereotype", Namespace.getNamespace(
								"UML", "omg.org/UML/1.4"));
				entityElementChildren.add(stereotypeModelElement);
				List<Element> stereotypeModelElementChildren = stereotypeModelElement
						.getChildren();

				Element stereotypeElement = new Element("Stereotype", Namespace
						.getNamespace("UML", "omg.org/UML/1.4"));
				Attribute hrefAttribute = null;
				if (areAllMethodsInWebServiceConfigFile(entityClass
						.getMethods())) {
					hrefAttribute = new Attribute("href",
							"andromda-profile-webservice-3.3.xml.zip|_9_0_1fe00f9_1119337599234_292426_17");
				} else {
					hrefAttribute = new Attribute("href",
							"andromda-profile-service-3.3.xml.zip|_9_0_1fe00f9_1119337557859_21792_59");
				}

				stereotypeElement.setAttribute(hrefAttribute);
				stereotypeModelElementChildren.add(stereotypeElement);
				List<Element> stereotypeElementChildren = stereotypeElement
						.getChildren();

				Element xmiExtensionElement = new Element("XMI.extension");
				Attribute extenderAttribute = new Attribute("xmi.extender",
						"MagicDraw UML 9.5");
				Attribute extenderIDAttribute = new Attribute("xmi.extenderID",
						"MagicDraw UML 9.5");
				xmiExtensionElement.setAttribute(extenderAttribute);
				xmiExtensionElement.setAttribute(extenderIDAttribute);
				stereotypeElementChildren.add(xmiExtensionElement);
				List<Element> xmiExtensionElementChildren = xmiExtensionElement
						.getChildren();

				Element referentPathElement = new Element("referentPath");
				Attribute valueAttribute = new Attribute("xmi.value",
						"org.andromda.profile::service::Service");
				referentPathElement.setAttribute(valueAttribute);
				xmiExtensionElementChildren.add(referentPathElement);

				Element featureElement = new Element("Classifier.feature",
						Namespace.getNamespace("UML", "omg.org/UML/1.4"));
				entityElementChildren.add(featureElement);
				List<Element> featureElementChildren = featureElement
						.getChildren();

				// methods
				List<MMethod> methods = entityClass.getMethods();
				for (MMethod method : methods) {
					Element operationElement = new Element("Operation",
							Namespace.getNamespace("UML", "omg.org/UML/1.4"));
					Attribute operationIDAttribute = new Attribute("xmi.id",
							Integer.toString(idCounter++));
					Attribute operationNameAttribute = new Attribute("name",
							method.getName());
					String visibility = "package";
					int modifiers = method.getModifiers();
					String modifierString = Modifier.toString(modifiers);
					if (modifierString.contains("public")) {
						visibility = "public";
					}
					if (modifierString.contains("private")) {
						visibility = "private";
					}
					if (modifierString.contains("protected")) {
						visibility = "protected";
					}

					Attribute methodVisibilityAttribute = new Attribute(
							"visibility", visibility);
					operationElement.setAttribute(operationIDAttribute);
					operationElement.setAttribute(operationNameAttribute);
					operationElement.setAttribute(methodVisibilityAttribute);
					addOwnerScopeAttribute(method, operationElement);
					featureElementChildren.add(operationElement);
					List<Element> operationElementChildren = operationElement
							.getChildren();

					if (!areAllMethodsInWebServiceConfigFile(entityClass
							.getMethods())) {
						if (method.isInWebServiceConfigFile()) {
							Element modelElementStereotype = new Element(
									"ModelElement.stereotype", Namespace
											.getNamespace("UML",
													"omg.org/UML/1.4"));
							operationElementChildren
									.add(modelElementStereotype);
							Element stereotypElement = new Element(
									"Stereotype", Namespace.getNamespace("UML",
											"omg.org/UML/1.4"));
							Attribute hrefAttribute2 = new Attribute("href",
									"andromda-profile-webservice-3.3.xml.zip|_9_0_1fe00f9_1119337599234_736026_12");
							stereotypElement.setAttribute(hrefAttribute2);
							modelElementStereotype.addContent(stereotypElement);

							Element xmiExtensionElement2 = new Element(
									"XMI.extension");
							Attribute extenderAttribute2 = new Attribute(
									"xmi.extender", "MagicDraw UML 9.5");
							Attribute extenderIDAttribute2 = new Attribute(
									"xmi.extenderID", "MagicDraw UML 9.5");
							xmiExtensionElement2
									.setAttribute(extenderAttribute2);
							xmiExtensionElement2
									.setAttribute(extenderIDAttribute2);
							stereotypElement.addContent(xmiExtensionElement2);

							Element referentPathElement2 = new Element(
									"referentPath");
							Attribute valueAttribute2 = new Attribute(
									"xmi.value",
									"org.andromda.profile::webservice::WebServiceOperation");
							referentPathElement2.setAttribute(valueAttribute2);
							xmiExtensionElement2
									.addContent(referentPathElement2);
						}
					}

					Element behavioralFeatureElement = new Element(
							"BehavioralFeature.parameter", Namespace
									.getNamespace("UML", "omg.org/UML/1.4"));
					operationElementChildren.add(behavioralFeatureElement);
					List<Element> behavioralFeatureElementChildren = behavioralFeatureElement
							.getChildren();

					Element returnParameterElement = new Element("Parameter",
							Namespace.getNamespace("UML", "omg.org/UML/1.4"));
					Attribute parameterIDAttribute = new Attribute("xmi.id",
							Integer.toString(idCounter++));
					Attribute parameterKindAttribute = new Attribute("kind",
							"return");
					returnParameterElement.setAttribute(parameterIDAttribute);
					returnParameterElement.setAttribute(parameterKindAttribute);
					behavioralFeatureElementChildren
							.add(returnParameterElement);
					List<Element> returnParameterElementChildren = returnParameterElement
							.getChildren();

					if (isBuildedDataType(method.getReturnType())) {
						Element parameterTypElement2 = new Element(
								"Parameter.type", Namespace.getNamespace("UML",
										"omg.org/UML/1.4"));
						returnParameterElementChildren
								.add(parameterTypElement2);
						List<Element> parameterTypElementChildren2 = parameterTypElement2
								.getChildren();

						Element classifierElement2 = new Element("Classifier",
								Namespace
										.getNamespace("UML", "omg.org/UML/1.4"));
						Attribute classifierHref2 = new Attribute("href",
								"andromda-profile-datatype-3.3.xml.zip|"
										+ getDataTypeCode(method
												.getReturnType()));
						classifierElement2.setAttribute(classifierHref2);
						parameterTypElementChildren2.add(classifierElement2);
						List<Element> classifierElementChildren2 = classifierElement2
								.getChildren();

						Element xmiExtensionElement3 = new Element(
								"XMI.extension");
						Attribute extenderAttribute3 = new Attribute(
								"xmi.extender", "MagicDraw UML 9.5");
						Attribute extenderIDAttribute3 = new Attribute(
								"xmi.extenderID", "MagicDraw UML 9.5");
						xmiExtensionElement3.setAttribute(extenderAttribute3);
						xmiExtensionElement3.setAttribute(extenderIDAttribute3);
						classifierElementChildren2.add(xmiExtensionElement3);
						List<Element> xmiExtensionElementChildren3 = xmiExtensionElement3
								.getChildren();

						Element referentPathElement3 = new Element(
								"referentPath");
						Attribute valueAttribute3 = new Attribute("xmi.value",
								method.getReturnType().getSimpleName());
						referentPathElement3.setAttribute(valueAttribute3);
						xmiExtensionElementChildren3.add(referentPathElement3);
					} else {
						returnParameterElement.setAttribute("type",
								getEntityIdForMClass(method.getReturnType()
										.getName(), entitiesList));
					}

					Map<String, Class> parameters = method.getParameters();
					Set<String> nameSet = parameters.keySet();
					for (String parameterName : nameSet) {
						Element parameterElement = new Element("Parameter",
								Namespace
										.getNamespace("UML", "omg.org/UML/1.4"));
						Attribute parameterIDAttribute2 = new Attribute(
								"xmi.id", Integer.toString(idCounter++));
						Attribute parameterKindAttribute2 = new Attribute(
								"name", parameterName);
						parameterElement.setAttribute(parameterIDAttribute2);
						parameterElement.setAttribute(parameterKindAttribute2);
						behavioralFeatureElementChildren.add(parameterElement);
						List<Element> parameterElementChildren = parameterElement
								.getChildren();

						if (isBuildedDataType(parameters.get(parameterName))) {
							Element parameterTypElement = new Element(
									"Parameter.type", Namespace.getNamespace(
											"UML", "omg.org/UML/1.4"));
							parameterElementChildren.add(parameterTypElement);
							List<Element> parameterTypElementChildren = parameterTypElement
									.getChildren();

							Element classifierElement = new Element(
									"Classifier", Namespace.getNamespace("UML",
											"omg.org/UML/1.4"));
							Attribute classifierHref = new Attribute("href",
									"andromda-profile-datatype-3.3.xml.zip|"
											+ getDataTypeCode(parameters
													.get(parameterName)));
							classifierElement.setAttribute(classifierHref);
							parameterTypElementChildren.add(classifierElement);
							List<Element> classifierElementChildren = classifierElement
									.getChildren();

							Element xmiExtensionElement2 = new Element(
									"XMI.extension");
							Attribute extenderAttribute2 = new Attribute(
									"xmi.extender", "MagicDraw UML 9.5");
							Attribute extenderIDAttribute2 = new Attribute(
									"xmi.extenderID", "MagicDraw UML 9.5");
							xmiExtensionElement2
									.setAttribute(extenderAttribute2);
							xmiExtensionElement2
									.setAttribute(extenderIDAttribute2);
							classifierElementChildren.add(xmiExtensionElement2);
							List<Element> xmiExtensionElementChildren2 = xmiExtensionElement2
									.getChildren();

							Element referentPathElement2 = new Element(
									"referentPath");
							Attribute valueAttribute2 = new Attribute(
									"xmi.value", parameters.get(parameterName)
											.getSimpleName());
							referentPathElement2.setAttribute(valueAttribute2);
							xmiExtensionElementChildren2
									.add(referentPathElement2);
						} else {
							parameterElement.setAttribute("type",
									getEntityIdForMClass(parameters.get(
											parameterName).getName(),
											entitiesList));
						}
					}
				}
			} else {
				System.out.println("No configuration file for web service: "
						+ entityClass.getName());
			}
		}
	}

	private void createValueObjects(Element ownedElement, List<Object> entities) {
		for (Object entity : entities) {
			MClass entityClass = (MClass) entity;
			List<Element> ownedElementCHildren = ownedElement.getChildren();

			Element entityElement = new Element("Class", Namespace
					.getNamespace("UML", "omg.org/UML/1.4"));
			List<Element> entityElementChildren = entityElement.getChildren();
			entitiyIds.add(entityCounter);
			entitiesList.add(entityClass);
			Attribute idAttribute = new Attribute("xmi.id", Integer
					.toString(entityCounter++));
			Attribute nameAttribute = new Attribute("name", entityClass
					.getName());
			entityElement.setAttribute(idAttribute);
			entityElement.setAttribute(nameAttribute);
			ownedElementCHildren.add(entityElement);

			Element stereotypeModelElement = new Element(
					"ModelElement.stereotype", Namespace.getNamespace("UML",
							"omg.org/UML/1.4"));
			entityElementChildren.add(stereotypeModelElement);
			List<Element> stereotypeModelElementChildren = stereotypeModelElement
					.getChildren();

			Element stereotypeElement = new Element("Stereotype", Namespace
					.getNamespace("UML", "omg.org/UML/1.4"));
			Attribute hrefAttribute = new Attribute("href",
					"andromda-profile-3.3.xml.zip|_9_0_1fe00f9_1119373197267_59537_10");
			stereotypeElement.setAttribute(hrefAttribute);
			stereotypeModelElementChildren.add(stereotypeElement);
			List<Element> stereotypeElementChildren = stereotypeElement
					.getChildren();

			Element xmiExtensionElement = new Element("XMI.extension");
			Attribute extenderAttribute = new Attribute("xmi.extender",
					"MagicDraw UML 9.5");
			Attribute extenderIDAttribute = new Attribute("xmi.extenderID",
					"MagicDraw UML 9.5");
			xmiExtensionElement.setAttribute(extenderAttribute);
			xmiExtensionElement.setAttribute(extenderIDAttribute);
			stereotypeElementChildren.add(xmiExtensionElement);
			List<Element> xmiExtensionElementChildren = xmiExtensionElement
					.getChildren();

			Element referentPathElement = new Element("referentPath");
			Attribute valueAttribute = new Attribute("xmi.value",
					"org.andromda.profile::ValueObject");
			referentPathElement.setAttribute(valueAttribute);
			xmiExtensionElementChildren.add(referentPathElement);

			// fields
			Element featureElement = new Element("Classifier.feature",
					Namespace.getNamespace("UML", "omg.org/UML/1.4"));
			entityElementChildren.add(featureElement);
			List<Element> featureElementChildren = featureElement.getChildren();

			List<MField> fields = entityClass.getFields();
			for (MField field : fields) {
				Element attributeElement = new Element("Attribute", Namespace
						.getNamespace("UML", "omg.org/UML/1.4"));
				Attribute attributeIDAttribute = new Attribute("xmi.id",
						Integer.toString(idCounter++));
				Attribute attributeNameAttribute = new Attribute("name", field
						.getName());
				String visibility = "package";
				int modifiers = field.getModifiers();
				String modifierString = Modifier.toString(modifiers);
				if (modifierString.contains("public")) {
					visibility = "public";
				}
				if (modifierString.contains("private")) {
					visibility = "private";
				}
				if (modifierString.contains("protected")) {
					visibility = "protected";
				}

				Attribute attributeVisibilityAttribute = new Attribute(
						"visibility", visibility);
				attributeElement.setAttribute(attributeIDAttribute);
				attributeElement.setAttribute(attributeNameAttribute);
				attributeElement.setAttribute(attributeVisibilityAttribute);
				featureElementChildren.add(attributeElement);
				List<Element> attributeElementChildren = attributeElement
						.getChildren();

				if (field.isStaticField())
					addUniqueStereotypeToAttribute(attributeElementChildren);
				if (field.isNotNull())
					addNotNullRangeToAttribute(attributeElementChildren);
				if (field.isIdentifier())
					addIdentifierStereotypeToAttribute(attributeElementChildren);
				Element featureTypeElement = new Element(
						"StructuralFeature.type", Namespace.getNamespace("UML",
								"omg.org/UML/1.4"));
				attributeElementChildren.add(featureTypeElement);
				List<Element> featureTypeElementChildren = featureTypeElement
						.getChildren();

				Element classifierElement = new Element("Classifier", Namespace
						.getNamespace("UML", "omg.org/UML/1.4"));
				Attribute classifierHref = new Attribute("href",
						"andromda-profile-datatype-3.3.xml.zip|"
								+ getDataTypeCode(field.getType()));
				classifierElement.setAttribute(classifierHref);
				featureTypeElementChildren.add(classifierElement);
				List<Element> classifierElementChildren = classifierElement
						.getChildren();

				Element xmiExtensionElement2 = new Element("XMI.extension");
				Attribute extenderAttribute2 = new Attribute("xmi.extender",
						"MagicDraw UML 9.5");
				Attribute extenderIDAttribute2 = new Attribute(
						"xmi.extenderID", "MagicDraw UML 9.5");
				xmiExtensionElement2.setAttribute(extenderAttribute2);
				xmiExtensionElement2.setAttribute(extenderIDAttribute2);
				classifierElementChildren.add(xmiExtensionElement2);
				List<Element> xmiExtensionElementChildren2 = xmiExtensionElement2
						.getChildren();

				Element referentPathElement2 = new Element("referentPath");
				Attribute valueAttribute2 = new Attribute("xmi.value",
						"datatype::" + field.getType().getSimpleName());
				referentPathElement2.setAttribute(valueAttribute2);
				xmiExtensionElementChildren2.add(referentPathElement2);

			}

			String valueObjectTarget = entityClass.getValueObjectTarget();
			if (valueObjectTarget != null && !valueObjectTarget.equals("")) {
				Element parentElement = ownedElement.getParentElement()
						.getParentElement().getParentElement()
						.getParentElement();
				List<Element> packageElements = parentElement.getChildren();
				for (Element element : packageElements) {
					String nameValue = element.getAttributeValue("name");
					if (nameValue.equals("domain")) {
						Element ownedElement2 = element
								.getChild("Namespace.ownedElement", Namespace
										.getNamespace("UML", "omg.org/UML/1.4"));
						Element packageElement2 = ownedElement2.getChild(
								"Package", Namespace.getNamespace("UML",
										"omg.org/UML/1.4"));
						Element ownedElement3 = packageElement2
								.getChild("Namespace.ownedElement", Namespace
										.getNamespace("UML", "omg.org/UML/1.4"));
						Element dependencyElement = new Element("Dependency",
								Namespace
										.getNamespace("UML", "omg.org/UML/1.4"));
						ownedElement3.addContent(dependencyElement);
						dependencyElement.setAttribute("xmi.id", Integer
								.toString(idCounter++));
						dependencyElement.setAttribute("client",
								getEntityIdForMClass(valueObjectTarget,
										entitiesList));
						dependencyElement.setAttribute("supplier", idAttribute
								.getValue());
					}
				}
			}
		}
	}

	private void createEntityReferences(Element xmiExtensionsElement,
			int entityCount, int idCounter, int modelNumber) {
		Element ownedDiagramsElement = xmiExtensionsElement
				.getChild("mdOwnedDiagrams");
		Element mdElement = ownedDiagramsElement.getChild("mdElement");
		Element parentId = mdElement.getChild("parentID");
		parentId.setAttribute("xmi.idref", Integer.toString(modelNumber));

		Element mdElement2 = mdElement.getChild("mdElement");
		Element mdOwnedViews = mdElement2.getChild("mdOwnedViews");
		List<Element> mdOwnedViewsChildren = mdOwnedViews.getChildren();

		for (int i = 0; i < entityCount; i++) {
			Element classViewElement = new Element("mdElement");
			Attribute elementClassAttribute = new Attribute("elementClass",
					"ClassView");
			Attribute classViewIDAttribute = new Attribute("xmi.id", Integer
					.toString(idCounter++));
			classViewElement.setAttribute(elementClassAttribute);
			classViewElement.setAttribute(classViewIDAttribute);
			mdOwnedViewsChildren.add(classViewElement);

			List<Element> classViewElementChildren = classViewElement
					.getChildren();
			Element elementID = new Element("elementID");
			Attribute idRef = new Attribute("xmi.idref", Integer
					.toString(i + 1));
			elementID.setAttribute(idRef);
			classViewElementChildren.add(elementID);
		}
	}

	private String getDataTypeCode(Class fieldType) {
		if (fieldType.equals(String.class))
			return "_9_0_1fe00f9_1119336925531_364079_66";
		if (fieldType.equals(Integer.class))
			return "_9_0_1fe00f9_1119336925531_479934_4";
		if (fieldType.equals(String[].class))
			return "_9_0_1fe00f9_1119336925531_132353_2";
		if (fieldType.equals(Object.class))
			return "_9_0_1fe00f9_1119336925531_60450_7";
		if (fieldType.equals(Byte.class))
			return "_9_0_1fe00f9_1119336925531_367136_10";
		if (fieldType.equals(Date.class))
			return "_9_0_1fe00f9_1119336925531_195604_13";
		if (fieldType.equals(Timestamp[].class))
			return "_9_0_1fe00f9_1119336925531_754532_15";
		if (fieldType.equals(Document.class))
			return "_9_0_1fe00f9_1119336925531_84233_20";
		if (fieldType.equals(Float.class))
			return "_9_0_1fe00f9_1119336925531_593311_21";
		if (fieldType.equals(URI.class))
			return "_9_0_1fe00f9_1119336925531_991330_22";
		if (fieldType.equals(Time.class))
			return "_9_0_1fe00f9_1119336925531_918521_25";
		if (fieldType.equals(Blob.class))
			return "_9_0_1fe00f9_1119336925531_193099_28";
		if (fieldType.equals(File[].class))
			return "_9_0_1fe00f9_1119336925531_473632_29";
		if (fieldType.equals(URI[].class))
			return "_9_0_1fe00f9_1119336925531_290366_31";
		if (fieldType.equals(Character[].class))
			return "_9_0_1fe00f9_1119336925531_788724_32";
		if (fieldType.equals(Integer[].class))
			return "_9_0_1fe00f9_1119336925531_700429_33";
		if (fieldType.equals(Double[].class))
			return "_9_0_1fe00f9_1119336925531_304971_37";
		if (fieldType.equals(URL.class))
			return "_9_0_1fe00f9_1119336925531_187398_38";
		if (fieldType.equals(Boolean[].class))
			return "_9_0_1fe00f9_1119336925531_35369_39";
		if (fieldType.equals(Boolean.class))
			return "_9_0_1fe00f9_1119336925531_877505_40";
		if (fieldType.equals(Byte[].class))
			return "_9_0_1fe00f9_1119336925531_995153_43";
		if (fieldType.equals(File.class))
			return "_9_0_1fe00f9_1119336925531_424824_45";
		if (fieldType.equals(Timestamp.class))
			return "_9_0_1fe00f9_1119336925531_281112_48";
		if (fieldType.equals(URL[].class))
			return "_9_0_1fe00f9_1119336925531_872061_49";
		if (fieldType.equals(Long[].class))
			return "_9_0_1fe00f9_1119336925531_346958_51";
		if (fieldType.equals(Clob.class))
			return "_9_0_1fe00f9_1119336925531_45790_53";
		if (fieldType.equals(Object[].class))
			return "_9_0_1fe00f9_1119336925531_827203_54";
		if (fieldType.equals(Double.class))
			return "_9_0_1fe00f9_1119336925531_221770_56";
		if (fieldType.equals(Float[].class))
			return "_9_0_1fe00f9_1119336925531_82915_57";
		if (fieldType.equals(Long.class))
			return "_9_0_1fe00f9_1119336925531_227130_59";
		if (fieldType.equals(Character.class))
			return "_9_0_1fe00f9_1119336925531_441057_63";
		if (fieldType.equals(Short[].class))
			return "_9_0_1fe00f9_1119336925531_100716_70";
		if (fieldType.equals(TreeNode.class))
			return "_9_0_1fe00f9_1119336925531_201529_72";
		if (fieldType.equals(Short.class))
			return "_9_0_1fe00f9_1119336925531_21075_73";
		if (fieldType.equals(Time[].class))
			return "_9_0_1fe00f9_1119336925531_425626_74";
		if (fieldType.equals(Date[].class))
			return "_9_0_1fe00f9_1119336925531_500158_76";
		if (fieldType.equals(void.class))
			return "_9_0_1fe00f9_1119336925531_324247_52";
		if (fieldType.equals(List.class))
			return "_9_0_1fe00f9_1119336925531_809265_8";

		return "";
	}

	private boolean isBuildedDataType(Class fieldType) {
		String dataTypeCode = getDataTypeCode(fieldType);
		if (dataTypeCode.length() > 0)
			return true;
		else
			return false;
	}

	private boolean isClassExported(String className, List<Object> entities) {
		for (Object entity : entities) {
			Type mClass = (Type) entity;
			if (className.equals(mClass.getName()))
				return true;
		}

		return false;
	}

	private String getEntityId(String className, List<Object> entities) {
		int index = 0;
		for (Object entity : entities) {
			Type mClass = (Type) entity;
			index++;
			if (className.equals(mClass.getName()))
				return Integer.toString(index);
		}

		return "-1";
	}

	private String getEntityIdForMClass(String className, List<Type> entities) {
		int index = 0;
		for (Type mClass : entities) {
			index++;
			if (className.equals(mClass.getName()))
				return Integer.toString(index);
		}

		return "-1";
	}

	private String getLowerMultiplictyOfField(MField field,
			List<Object> entities) {
		if (field.getMinimalMultiplicity() == null) {
			return "0";
		}

		String minMultiplicity = field.getMinimalMultiplicity();
		if (minMultiplicity.length() > 0) {
			return minMultiplicity;
		}

		return "0";
	}

	private String getUpperMultiplictyOfField(MField field,
			List<Object> entities) {
		return field.getMaximalMultiplicity();
	}

	private Collection<String> getAllPackagesFromClasses(
			Map<String, List<Object>> filteredGraph) {
		Collection<String> result = new ArrayList<String>();

		Set<String> keySet = filteredGraph.keySet();
		for (String key : keySet) {
			List<Object> classesList = filteredGraph.get(key);
			for (Object classObject : classesList) {
				if (classObject instanceof MClass) {
					MClass mClass = (MClass) classObject;
					String packageName = mClass.getPackageName();
					if (!result.contains(packageName))
						result.add(packageName);
				}
			}
		}

		return result;
	}

	private boolean isSetterOrGetterMethod(MMethod method, List<MField> fields) {
		return isSetterMethod(method, fields) || isGetterMethod(method, fields);
	}

	private boolean isSetterMethod(MMethod method, List<MField> fields) {
		String methodName = method.getName();
		if (!methodName.startsWith("set"))
			return false;

		String fieldOfTheMethod = methodName.substring(3).toLowerCase();
		for (MField field : fields) {
			if (fieldOfTheMethod.equals(field.getName().toLowerCase()))
				return true;
		}

		return false;
	}

	private boolean isGetterMethod(MMethod method, List<MField> fields) {
		String methodName = method.getName();
		if (!methodName.startsWith("get") && !methodName.startsWith("is"))
			return false;

		String fieldOfTheMethod = methodName.substring(3).toLowerCase();
		String fieldOfTheMethod2 = methodName.substring(2).toLowerCase();
		for (MField field : fields) {
			if (fieldOfTheMethod.equals(field.getName().toLowerCase())
					|| fieldOfTheMethod2.equals(field.getName().toLowerCase()))
				return true;
		}

		return false;
	}

	private void addOwnerScopeAttribute(MMethod method, Element operationElement) {
		int methodModifiers = method.getModifiers();
		String modifiersString = Modifier.toString(methodModifiers);
		if (modifiersString.contains("static")) {
			Attribute ownerScope = new Attribute("ownerScope", "classifier");
			operationElement.setAttribute(ownerScope);
		}
	}

	private void addUniqueStereotypeToAttribute(
			List<Element> attributeElementsList) {
		Element modelElementStereotype = new Element("ModelElement.stereotype",
				Namespace.getNamespace("UML", "omg.org/UML/1.4"));
		attributeElementsList.add(modelElementStereotype);
		Element stereotypElement = new Element("Stereotype", Namespace
				.getNamespace("UML", "omg.org/UML/1.4"));
		Attribute hrefAttribute = new Attribute("href",
				"andromda-profile-persistence-3.3.xml.zip|_9_0_1fe00f9_1119337118921_432579_74");
		stereotypElement.setAttribute(hrefAttribute);
		modelElementStereotype.addContent(stereotypElement);

		Element xmiExtensionElement = new Element("XMI.extension");
		Attribute extenderAttribute = new Attribute("xmi.extender",
				"MagicDraw UML 9.5");
		Attribute extenderIDAttribute = new Attribute("xmi.extenderID",
				"MagicDraw UML 9.5");
		xmiExtensionElement.setAttribute(extenderAttribute);
		xmiExtensionElement.setAttribute(extenderIDAttribute);
		stereotypElement.addContent(xmiExtensionElement);

		Element referentPathElement = new Element("referentPath");
		Attribute valueAttribute = new Attribute("xmi.value",
				"org.andromda.profile::persistence::Unique");
		referentPathElement.setAttribute(valueAttribute);
		xmiExtensionElement.addContent(referentPathElement);
	}

	private void addNotNullRangeToAttribute(List<Element> attributeElementsList) {
		Element structuralFeatureElement = new Element(
				"StructuralFeature.multiplicity", Namespace.getNamespace("UML",
						"omg.org/UML/1.4"));
		attributeElementsList.add(structuralFeatureElement);
		Element multiplicityElement = new Element("Multiplicity", Namespace
				.getNamespace("UML", "omg.org/UML/1.4"));
		Attribute attributeIDAttribute = new Attribute("xmi.id", Integer
				.toString(idCounter++));
		multiplicityElement.setAttribute(attributeIDAttribute);
		structuralFeatureElement.addContent(multiplicityElement);

		Element rangeElement = new Element("Multiplicity.range", Namespace
				.getNamespace("UML", "omg.org/UML/1.4"));
		multiplicityElement.addContent(rangeElement);

		Element multiplicityRangeElement = new Element("MultiplicityRange",
				Namespace.getNamespace("UML", "omg.org/UML/1.4"));
		Attribute idAttribute = new Attribute("xmi.id", Integer
				.toString(idCounter++));
		Attribute lowerAttribute = new Attribute("lower", "1");
		Attribute upperAttribute = new Attribute("upper", "1");
		multiplicityRangeElement.setAttribute(idAttribute);
		multiplicityRangeElement.setAttribute(lowerAttribute);
		multiplicityRangeElement.setAttribute(upperAttribute);
		rangeElement.addContent(multiplicityRangeElement);
	}

	private void addIdentifierStereotypeToAttribute(
			List<Element> attributeElementsList) {
		Element modelElementStereotype = new Element("ModelElement.stereotype",
				Namespace.getNamespace("UML", "omg.org/UML/1.4"));
		attributeElementsList.add(modelElementStereotype);
		Element stereotypElement = new Element("Stereotype", Namespace
				.getNamespace("UML", "omg.org/UML/1.4"));
		Attribute hrefAttribute = new Attribute("href",
				"andromda-profile-persistence-3.3.xml.zip|_9_0_1fe00f9_1119337118921_176418_96");
		stereotypElement.setAttribute(hrefAttribute);
		modelElementStereotype.addContent(stereotypElement);

		Element xmiExtensionElement = new Element("XMI.extension");
		Attribute extenderAttribute = new Attribute("xmi.extender",
				"MagicDraw UML 9.5");
		Attribute extenderIDAttribute = new Attribute("xmi.extenderID",
				"MagicDraw UML 9.5");
		xmiExtensionElement.setAttribute(extenderAttribute);
		xmiExtensionElement.setAttribute(extenderIDAttribute);
		stereotypElement.addContent(xmiExtensionElement);

		Element referentPathElement = new Element("referentPath");
		Attribute valueAttribute = new Attribute("xmi.value",
				"org.andromda.profile::persistence::Identifier");
		referentPathElement.setAttribute(valueAttribute);
		xmiExtensionElement.addContent(referentPathElement);
	}

	private List<Object> filterClassesByPackageName(List<Object> entities,
			String packageName) {
		List<Object> resultList = new ArrayList<Object>();
		for (Object object : entities) {
			if (object instanceof Type) {
				Type mClass = (Type) object;
				if (mClass.getPackageName() != null
						&& mClass.getPackageName().equals(packageName))
					resultList.add(object);
			}
		}

		return resultList;
	}

	private boolean areAllMethodsInWebServiceConfigFile(
			List<MMethod> mtehodsList) {
		for (MMethod method : mtehodsList) {
			if (!method.isInWebServiceConfigFile())
				return false;
		}

		return true;
	}
}
